import React, { useState, useEffect } from 'react'
import { Button } from "antd"
import { CloudUploadOutlined } from '@ant-design/icons';
import * as echarts from 'echarts';
import style from '../index.module.scss'


export default function Echarts1(props) {
    const [main, setMain] = useState('')
    const option = {
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['新用户增长']
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['2017-07-01', '2017-07-04', '2017-07-07', '2017-07-13', '2017-07-16', '2017-07-19', '2017-07-22', '2017-07-25', '2017-07-28', '2017-07-31']
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                name: '新用户增长',
                stack: 'Total',
                data: [0, 6, 4, 6, 12, 2, 8, 1, 5, 3],
                type: 'line'
            }
        ]
    };
    useEffect(() => {
        var node = document.getElementById('main')
        setMain(node)
    }, [])
    // 基于准备好的dom，初始化echarts实例
    if (main !== "") {
        var myChart = echarts.init(main);
        myChart.resize({ height: '400px' })
        myChart.setOption(option);
    }
    return (
        <div>
            <div className={style.pre_title}>
                <p>新增注册用户数</p>
                <Button className='button'><CloudUploadOutlined className="icon" />导出</Button>
            </div>
            <div id="main"></div>
        </div>
    )
}
